home *** CD-ROM | disk | FTP | other *** search
/ Scene 96 / Scene 96 International Edition (Zyklop Software) (Disc 2) (1997).iso / misc / coding / midas060 / src / sdevice.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-16  |  11.4 KB  |  307 lines

  1. /*      SDEVICE.H
  2.  *
  3.  * Sound Device definitions
  4.  *
  5.  * $Id: sdevice.h,v 1.9 1997/01/16 18:41:59 pekangas Exp $
  6.  *
  7.  * Copyright 1996,1997 Housemarque Inc.
  8.  *
  9.  * This file is part of the MIDAS Sound System, and may only be
  10.  * used, modified and distributed under the terms of the MIDAS
  11.  * Sound System license, LICENSE.TXT. By continuing to use,
  12.  * modify or distribute this file you indicate that you have
  13.  * read the license and understand and accept it fully.
  14. */
  15.  
  16.  
  17. #ifndef __SDEVICE_H
  18. #define __SDEVICE_H
  19.  
  20. #ifdef __16__
  21. #define SMPMAX 65519                    /* max sample length (65536-16 - 1) */
  22. #else
  23. #define SMPMAX 2147483631               /* max sample length (2^31 - 17) */
  24. #endif
  25. #define MAXSAMPLES 256                  /* maximum number of samples */
  26.  
  27. #define DMABUFLEN 25                    /* mixing buffer length is a 1/25th of
  28.                                            a second */
  29.  
  30.  
  31.  
  32. /****************************************************************************\
  33. *       enum sdSampleType
  34. *       -----------------
  35. * Description:  Sample types
  36. \****************************************************************************/
  37.  
  38. enum sdSampleType
  39. {
  40.     smpNone = 0,                        /* no sample */
  41.     smp8bitMono = 1,                    /* 8-bit mono unsigned sample */
  42.     smp8bit = smp8bitMono,              /* for compatibility */
  43.     smp16bitMono = 2,                   /* 16-bit mono signed sample */
  44.     smp16bit = smp16bitMono,            /* for compatibility */
  45.     smp8bitStereo = 3,                  /* 8-bit stereo unsigned sample */
  46.     smp16bitStereo = 4                  /* 16-bit stereo signed sample */
  47. };
  48.  
  49.  
  50.  
  51.  
  52. /****************************************************************************\
  53. *       enum sdLoopMode
  54. *       ---------------
  55. * Description:  Sample looping modes
  56. \****************************************************************************/
  57.  
  58. enum sdLoopMode
  59. {
  60.     sdLoopNone = 0,                     /* no looping */
  61.     sdLoop1 = 1,                        /* 1 loop, release ends note */
  62.     sdLoop1Rel = 2,                     /* 1 loop, sample data after loop is
  63.                                            played when note is released */
  64.     sdLoop2 = 3,                        /* 2 loops, when note is released
  65.                                            playing is continued looping the
  66.                                            second loop */
  67.     sdLoopAmigaNone = 4,                /* Amiga compatible looping, no
  68.                                            loop - ALE logic enabled anyway */
  69.     sdLoopAmiga = 5                     /* Amiga compatible looping - 1
  70.                                            loop, ALE logic enabled */
  71. };
  72.  
  73.  
  74.  
  75.  
  76. /****************************************************************************\
  77. *       enum sdLoopType
  78. *       ---------------
  79. * Description:  Sample looping type for one loop
  80. \****************************************************************************/
  81.  
  82. enum sdLoopType
  83. {
  84.     loopNone = 0,                       /* no looping */
  85.     loopUnidir = 1,                     /* unidirectional loop */
  86.     loopBidir = 2                       /* bidirectional loop */
  87. };
  88.  
  89.  
  90.  
  91.  
  92. /****************************************************************************\
  93. *       enum sdSmpPos
  94. *       -------------
  95. * Description:  Sample positions in memory
  96. \****************************************************************************/
  97.  
  98. enum sdSmpPos
  99. {
  100.     sdSmpNone = 0,                   /* no sample */
  101.     sdSmpConv,                       /* conventional memory */
  102.     sdSmpEMS                         /* EMS */
  103. };
  104.  
  105.  
  106.  
  107.  
  108. /****************************************************************************\
  109. *       struct sdSample
  110. *       ---------------
  111. * Description:  Sound Device sample information structure
  112. \****************************************************************************/
  113.  
  114. typedef struct
  115. {
  116.     uchar       *sample;                /* sample data pointer */
  117.     int         samplePos;              /* sample position in memory, see enum
  118.                                            sdSmpPos */
  119.     int         sampleType;             /* sample type, see enum
  120.                                            sdSampleType */
  121.     unsigned    sampleLength;           /* sample length */
  122.     int         loopMode;               /* sample looping mode, see enum
  123.                                            sdLoopMode */
  124.     unsigned    loop1Start;             /* first loop start */
  125.     unsigned    loop1End;               /* first loop end */
  126.     int         loop1Type;              /* first loop type, see enum
  127.                                            sdLoopType */
  128.     unsigned    loop2Start;             /* second loop start */
  129.     unsigned    loop2End;               /* second loop end */
  130.     int         loop2Type;              /* second loop type, see enum
  131.                                            sdLoopType */
  132. } sdSample;
  133.  
  134.  
  135.  
  136.  
  137. /****************************************************************************\
  138. *       enum sdPanning
  139. *       --------------
  140. * Description:  Sound Device panning values. Legal values range from
  141. *               panLeft to panRight, in steps of 1, plus panSurround.
  142. *               Surround sound is played from middle if surround is not
  143. *               enabled.
  144. \****************************************************************************/
  145.  
  146. enum sdPanning
  147. {
  148.     panLeft = -64,                      /* left speaker */
  149.     panMiddle = 0,                      /* middle (both speakers) */
  150.     panRight = 64,                      /* right speaker */
  151.     panSurround = 0x80                  /* surround sound */
  152. };
  153.  
  154.  
  155.  
  156.  
  157. /****************************************************************************\
  158. *       enum sdMode
  159. *       -----------
  160. * Description:  Possible SoundDevice output modes
  161. \****************************************************************************/
  162.  
  163. enum sdMode
  164. {
  165.     sdMono = 1,                         /* mono */
  166.     sdStereo = 2,                       /* stereo */
  167.  
  168.     sd8bit = 4,                         /* 8-bit output */
  169.     sd16bit = 8                         /* 16-bit output */
  170. };
  171.  
  172.  
  173.  
  174.  
  175. /****************************************************************************\
  176. *       enum sdConfigBits
  177. *       -----------------
  178. * Description:  Sound Device configuration information bits
  179. \****************************************************************************/
  180.  
  181. enum sdConfigBits
  182. {
  183.     sdUsePort = 1,                      /* SD uses an I/O port */
  184.     sdUseIRQ = 2,                       /* SD uses an IRQ */
  185.     sdUseDMA = 4,                       /* SD uses a DMA channel */
  186.     sdUseMixRate = 8,                   /* SD uses the set mixing rate */
  187.     sdUseOutputMode = 16,               /* SD uses the set output mode */
  188.     sdUseDSM = 32                       /* SD uses software mixing (DSM) */
  189. };
  190.  
  191.  
  192.  
  193.  
  194. /****************************************************************************\
  195. *       struct SoundDevice
  196. *       ------------------
  197. * Description:  SoundDevice structure. See SDEVICE.TXT for documentation
  198. \****************************************************************************/
  199.  
  200. typedef struct
  201. {
  202.     unsigned    tempoPoll;
  203.     unsigned    configBits;             /* Configuration info bits. See enum
  204.                                            sdConfigBits. */
  205.     unsigned    port;                   /* Sound Device I/O port address */
  206.     unsigned    IRQ;                    /* Sound Device IRQ number */
  207.     unsigned    DMA;                    /* Sound Device DMA channel number */
  208.     unsigned    cardType;               /* Sound Device sound card type.
  209.                                            Starting from 1, 0 means
  210.                                            autodetect */
  211.     unsigned    numCardTypes;           /* number of different sound card
  212.                                            types for this Sound Device */
  213.     unsigned    modes;                  /* Possible modes for this SD,
  214.                                            see enum sdMode. Updated by
  215.                                            Detect() */
  216.  
  217.     char        *name;                  /* pointer to Sound Device name */
  218.     char        **cardNames;            /* pointer to an array of pointers to
  219.                                            sound card name strings */
  220.     unsigned    numPortAddresses;       /* number of possible port
  221.                                            addresses in table */
  222.     unsigned    *portAddresses;         /* pointer to an array of possible
  223.                                            I/O port addresses */
  224.  
  225.  
  226.     int (CALLING *Detect)(int *result);
  227.     int (CALLING *Init)(unsigned mixRate, unsigned mode);
  228.     int (CALLING *Close)(void);
  229.     int (CALLING *GetMixRate)(unsigned *mixRate);
  230.     int (CALLING *GetMode)(unsigned *mode);
  231.     int (CALLING *OpenChannels)(unsigned channels);
  232.     int (CALLING *CloseChannels)(void);
  233.     int (CALLING *ClearChannels)(void);
  234.     int (CALLING *Mute)(int mute);
  235.     int (CALLING *Pause)(int pause);
  236.     int (CALLING *SetMasterVolume)(unsigned masterVolume);
  237.     int (CALLING *GetMasterVolume)(unsigned *masterVolume);
  238.     int (CALLING *SetAmplification)(unsigned amplification);
  239.     int (CALLING *GetAmplification)(unsigned *amplification);
  240.     int (CALLING *PlaySound)(unsigned channel, ulong rate);
  241.     int (CALLING *ReleaseSound)(unsigned channel);
  242.     int (CALLING *StopSound)(unsigned channel);
  243.     int (CALLING *SetRate)(unsigned channel, ulong rate);
  244.     int (CALLING *GetRate)(unsigned channel, ulong *rate);
  245.     int (CALLING *SetVolume)(unsigned channel, unsigned volume);
  246.     int (CALLING *GetVolume)(unsigned channel, unsigned *volume);
  247.     int (CALLING *SetSample)(unsigned channel, unsigned smpHandle);
  248.     int (CALLING *GetSample)(unsigned channel, unsigned *smpHandle);
  249.     int (CALLING *SetPosition)(unsigned channel, unsigned pos);
  250.     int (CALLING *GetPosition)(unsigned channel, unsigned *pos);
  251.     int (CALLING *GetDirection)(unsigned channel, int *direction);
  252.     int (CALLING *SetPanning)(unsigned channel, int panning);
  253.     int (CALLING *GetPanning)(unsigned channel, int *panning);
  254.     int (CALLING *MuteChannel)(unsigned channel, int mute);
  255.     int (CALLING *AddSample)(sdSample *sample, int copySample,
  256.         unsigned *smpHandle);
  257.     int (CALLING *RemoveSample)(unsigned smpHandle);
  258.     int (CALLING *SetUpdRate)(unsigned updRate);
  259.     int (CALLING *StartPlay)(void);
  260.     int (CALLING *Play)(int *callMP);
  261.  
  262. #ifdef SUPPORTSTREAMS
  263.     int (CALLING *StartStream)(unsigned channel, uchar *buffer, unsigned
  264.         bufferLength, int sampleType, ulong rate);
  265.     int (CALLING *StopStream)(unsigned channel);
  266.     int (CALLING *SetLoopCallback)(unsigned channel, void (CALLING *callback)
  267.         (unsigned channel));
  268.     int (CALLING *SetStreamWritePosition)(unsigned channel,
  269.         unsigned position);
  270. #endif
  271. } SoundDevice;
  272.  
  273.  
  274.  
  275. #endif
  276.  
  277.  
  278. /*
  279.  * $Log: sdevice.h,v $
  280.  * Revision 1.9  1997/01/16 18:41:59  pekangas
  281.  * Changed copyright messages to Housemarque
  282.  *
  283.  * Revision 1.8  1997/01/16 18:21:23  pekangas
  284.  * Added function SetStreamWritePosition
  285.  *
  286.  * Revision 1.7  1996/10/09 17:59:59  pekangas
  287.  * Fixed to conform to the Sound Device specification
  288.  *
  289.  * Revision 1.6  1996/07/13 18:01:30  pekangas
  290.  * Fixed to compile with Visual C
  291.  *
  292.  * Revision 1.5  1996/05/28 20:28:45  pekangas
  293.  * Fixed a minor but annoying typo
  294.  *
  295.  * Revision 1.4  1996/05/26 20:56:17  pekangas
  296.  * Added rate to SoundDevice.StartStream prototype
  297.  *
  298.  * Revision 1.3  1996/05/24 16:20:36  jpaana
  299.  * Fixed for Linux
  300.  *
  301.  * Revision 1.2  1996/05/23 18:24:02  pekangas
  302.  * Added 8-bit stereo and 16-bit mono & stereo sample types and stream playing functions
  303.  *
  304.  * Revision 1.1  1996/05/22 20:49:33  pekangas
  305.  * Initial revision
  306.  *
  307. */